package com.company.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.company.project.entity.SysUser;
import com.company.project.service.HttpSessionService;
import com.company.project.service.RoleService;
import com.company.project.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.company.project.mapper.TCzjlMapper;
import com.company.project.entity.TCzjlEntity;
import com.company.project.service.TCzjlService;

import javax.annotation.Resource;
import java.util.List;


@Service("tCzjlService")
public class TCzjlServiceImpl extends ServiceImpl<TCzjlMapper, TCzjlEntity> implements TCzjlService {
    @Autowired
    private TCzjlMapper czjlMapper;
    @Autowired
    private HttpSessionService httpSessionService;
    @Autowired
    private UserService userService;
    @Resource
    private RoleService roleService;

    @Override
    public IPage<TCzjlEntity> pageList(Page page, TCzjlEntity tCzjl) {
        String userId = httpSessionService.getCurrentUserId();
        SysUser sysUser = userService.getById(userId);
        List<String> sysRoleNames = roleService.getRoleNames(userId);
        String roleName = sysRoleNames.get(0);
        return czjlMapper.pageList(page,tCzjl,sysUser,roleName);
    }
}